# import requests
# from requests import session
# {"scene": "1",
#  "username": "13089498921",
#  "verify_code": "8888",
#  "password": "519475228fe35ad067744465c42a19b2",
#  "password2": "519475228fe35ad067744465c42a19b2"}

# import requests
#
#
# class Register(object):
#     # def setup_class(self):
#     #     self.session = requests.Session()
#     #     self.session.get(url="http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg")
#     def setup(self):
#         self.session = requests.Session()
#
#     def get_code(self):
#         self.session.get(url="http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg")
#
#     def register(self, req_data):
#         # sess = requests.Session()
#         # sess.get(url="http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg")
#         resp = self.session.post(url="http://hmshop-test.itheima.net/Home/User/reg.html",
#                                  data=req_data)
#         print(resp.json())
#         return resp
#
#
# if __name__ == '__main__':
#     test_reg = Register()
#     ret1= test_reg.setup()
#     ret2= test_reg.get_code()
#     resp = test_reg.register({"scene": "1",
#                               "username": "13089498921",
#                               "verify_code": "8888",
#                               "password": "519475228fe35ad067744465c42a19b2",
#                               "password2": "519475228fe35ad067744465c42a19b2"})
#     print(resp.json())

import requests


class TpshopRegister(object):

    def get_varify_code(self, session):
        session.get(url="http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg")

    def register(self, session, req_data):
        resp = session.post(url="http://hmshop-test.itheima.net/Home/User/reg.html",
                            data=req_data)
        # print(resp.json())
        return resp


if __name__ == '__main__':
    test_reg = TpshopRegister()
    session = requests.Session()
    ret1 = test_reg.get_varify_code(session)
    resp = test_reg.register(session, {"scene": "1",
                                       "username": "13089498927",
                                       "verify_code": "8888",
                                       "password": "519475228fe35ad067744465c42a19b2",
                                       "password2": "519475228fe35ad067744465c42a19b2"})
    print(resp.json())